library(raster)
library(plyr)
library(dplyr)
library(reshape)
library(ggplot2)
library(ggpmisc)
library(ggpubr)
library(viridisLite)
library(colorspace)
library(RColorBrewer)
library(sf)
library(stringr)
memory.limit(size = 160000)
## [1] Inf
#display.brewer.pal(n = 11, name ="RdYlBu")
colorvec <- brewer.pal(n = 11, name ="RdYlGn")
col.martonne <- c("Desert" = colorvec[2], "Arid"= colorvec[4],"Semi-arid"= colorvec[5], "Temperate" = colorvec[8], "Humid"= colorvec[10],"Forest"= colorvec[11])
col.cat <- c("Hyperarid" = colorvec[2], "Arid"= colorvec[4],"Semi-arid"= colorvec[5], "Dry subhumid" = colorvec[8], "Humid"= colorvec[10], "NA" = "#D5D8DC")
Liens utiles:
# era5vA <- read.table("era5_AI.txt") %>%
# mutate(tas = tas-273.15, pr = mpr * 60 * 60 * 24 * 365, rsds = ssrd / (60*60*24) * 1e-6 * 60*60*24) %>% # conversion from J/m2 to J/sm2 to MJ/m2/day
# select(c("lon","lat","Continent","Type","Name","Acronym","lm","model","source","pr","tas","sfcWind","Rn","rsds","ea","ET0","AI","cat.AI"))
#
#
# write.table(era5vA, "era5vA.txt")
era5vA <- read.table("ERA5/era5_AI.txt") %>%
mutate(z = z, tas = t2m - 273.15, sfcWind = wind, model = "historical", source = "ERA5") %>% #pr, ET0 already in mm/year
select(c("lon","lat","Continent","Type","Name","Acronym","lm","model","source","pr","tas","sfcWind","Rn","ea","z","ET0","AI","cat.AI")) %>%
filter(lm == 1)
write.table(era5vA, "era5vA.txt")
wdcvA <- read.table("wdc_AI.txt") %>% mutate(z = z, ea = vapr, ET0 = ET0) %>% # srad in MJ/m2/day, pr and ETO already in mm/year
select(c("lon","lat","Continent","Type","Name","Acronym","lm","model","source","pr","tas","sfcWind","Rn", "ea","z","ET0","AI","cat.AI"))
write.table(wdcvA, "wdcvA.txt")
cmip6 <- read.table("cmip6_AI.txt")
cmip6vA <- cmip6 %>% subset(period == "1970_2000") %>%
group_by(lon,lat,Continent, Type, Name, Acronym, lm, model, z) %>%
dplyr::summarise(tas = mean(tas, na.rm = T) - 273.15, pr = mean(spr, na.rm = T), # pr in mm/year
sfcWind = mean(sfcWind, na.rm = T), Rn = mean(Rn, na.rm = T),
ea = mean(ea, na.rm = T), ET0 = mean(sET0, na.rm = T), AI = mean(AI, na.rm = T)) %>% # ET0 in mm/year
ungroup() %>%
mutate(source = "CMIP6")%>%
select(c("lon","lat","Continent","Type","Name","Acronym","lm","model","source","pr","tas","sfcWind","Rn", "ea","z","ET0","AI"))
breaks.unesco <- c(-Inf,0,0.03,0.2,0.5,0.65,Inf)
cat.unesco <- c("(0,0.03]"= "Hyperarid", "(0.03,0.2]" = "Arid", "(0.2,0.5]" = "Semi-arid", "(0.5,0.65]" = "Dry subhumid","(0.65, Inf]" = "Humid", "(-Inf,0]" = "Cold")
col.cat <- c("Hyperarid" = colorvec[2], "Arid"= colorvec[4],"Semi-arid"= colorvec[5], "Dry subhumid" = colorvec[8], "Humid"= colorvec[10], "Cold" = "powderblue")
cmip6vA$cat.AI <- cmip6vA$AI %>% cut(breaks = breaks.unesco) %>% revalue(cat.unesco)
cmip6vA$cat.AI[which(cmip6vA$ET0 < 400)] <- "Cold"
write.table(cmip6vA, "cmip6vA.txt")
era5vA <- read.table("era5vA.txt")
wdcvA <- read.table("wdcvA.txt")
cmip6vA <- read.table("cmip6vA.txt")
comp <- merge(select(era5vA, c("lon","lat","source","Continent","z","Rn","ET0","AI","cat.AI")),
select(wdcvA, c("lon","lat","source","Continent","z","Rn","ET0","AI","cat.AI")), by = c("lon","lat")) %>%
merge(select(cmip6vA, c("lon","lat","source","Continent","z","ET0","AI","cat.AI")), by = c("lon","lat"))
subset(comp, is.na(cat.AI.x) & !is.na(cat.AI.y)) %>% View()
calib <- rbind(cmip6vA, era5vA, wdcvA)
breaks.unesco <- c(-Inf,0,0.03,0.2,0.5,0.65,Inf)
cat.unesco <- c("(0,0.03]"= "Hyperarid", "(0.03,0.2]" = "Arid", "(0.2,0.5]" = "Semi-arid", "(0.5,0.65]" = "Dry subhumid","(0.65, Inf]" = "Humid", "(-Inf,0]" = "Cold")
col.cat <- c("Hyperarid" = colorvec[2], "Arid"= colorvec[4],"Semi-arid"= colorvec[5], "Dry subhumid" = colorvec[8], "Humid"= colorvec[10], "Cold" = "powderblue")
calib$cat.AI <- calib$AI %>% cut(breaks = breaks.unesco) %>% revalue(cat.unesco)
calib$cat.AI[which(calib$ET0 < 400)] <- "Cold"
ggarrange(ggplot(data = subset(calib, source == "Worldclim")) + geom_raster(aes(x=lon, y = lat, fill = cat.AI))+
scale_fill_manual(values = col.cat)+
labs(title = "Wordclim, 1970-2000", fill = "")+
ylim(-55,90)+
theme_void()+
theme(legend.position = "none"),
ggplot(data = subset(calib, source == "ERA5")) + geom_raster(aes(x=lon, y = lat, fill = cat.AI))+
scale_fill_manual(values = col.cat)+
labs(title = "ERA5, 1970-2000", fill = "")+
ylim(-55,90)+
theme_void()+
theme(legend.position = "none"),
ggplot(data = subset(calib, source == "CMIP6")) + geom_raster(aes(x=lon, y = lat, fill = cat.AI))+
scale_fill_manual(values = col.cat)+
labs(title = "CMIP6, 1970-2000", fill = "")+
ylim(-55,90)+
theme_void()+
theme(legend.position = "none"),
ggplot(data = subset(calib, source == "Worldclim")) + geom_raster(aes(x = lon, y = lat, fill = cat.AI))+
geom_raster(aes(x = lon, y = lat), fill = "white")+
scale_fill_manual(values = col.cat)+
labs(title = "", fill = "")+
theme_void()+
theme(legend.position = "left")
)
# table_calib_c <- calib %>% select(c("Continent","source","cat.AI")) %>%
# reshape2::melt(id.vars = c("Continent","source")) %>%
# group_by(Continent,source,value) %>%
# summarise(count = n()) %>% mutate(perc = round(count/sum(count)*100,1)) %>%
# ungroup()
#
# table_calib_c$value[is.na(table_calib_c$value) == T] <- "NA"
#
# ggplot(table_calib_c)+
# geom_col(aes(x = Continent, y = perc, fill = value, position = "fill"))+
# scale_fill_manual(values = col.cat, breaks = c("Hyperarid","Arid","Semi-arid","Dry subhumid","Humid","NA"))+
# theme_minimal()+
# theme(axis.text.x = element_text(angle = 90, hjust = 1, vjust = 0.5))+
# facet_grid(rows = vars(source))+
# labs(x = "Continent", y = "%", fill = "Aridity\ncategory", y = "Proportion of aridity category")
#
table_calib <- calib %>% select(c("Continent","Name","Acronym","source","cat.AI")) %>%
reshape2::melt(id.vars = c("Continent","Name","Acronym","source")) %>%
group_by(Continent,Name,Acronym,source,value) %>%
summarise(count = n()) %>% mutate(perc = round(count/sum(count)*100,1)) %>%
ungroup() %>% filter(!Continent %in% c("SOUTHERN","PACIFIC","POLAR","ATLANTIC","INDIAN","ARCTIC"))
table_calib$value[is.na(table_calib$value) == T] <- "NA"
table_calib$Continent[which(table_calib$Continent == "EUROPE-AFRICA")] <- "EUROPE"
table_calib$Continent[which(table_calib$Continent == "CENTRAL-AMERICA")] <- "CENTRAL\nAMERICA"
table_calib$Continent[which(table_calib$Continent == "NORTH-AMERICA")] <- "NORTH\nAMERICA"
table_calib$Continent[which(table_calib$Continent == "SOUTH-AMERICA")] <- "SOUTH\nAMERICA"
table_calib$Continent <- factor(table_calib$Continent, levels = c("AFRICA","EUROPE","ASIA","OCEANIA","NORTH\nAMERICA","CENTRAL\nAMERICA","SOUTH\nAMERICA"))
ggplot(table_calib)+
geom_col(aes(x = Acronym, y = perc, fill = value, position = "fill"))+
scale_fill_manual(values = col.cat, breaks = c("Hyperarid","Arid","Semi-arid","Dry subhumid","Humid","NA"))+
theme_minimal()+
theme(axis.text.x = element_text(angle = 90, hjust = 1, vjust = 0.5),
legend.position = "bottom",
strip.text.x = element_text(size = 6))+
facet_grid(source ~ Continent, switch = "y", scales = "free_x", space = "free")+
labs(x = "", y = "%", fill = "Aridity\ncategory")
ggplot(table_calib)+
geom_col(aes(x = Acronym, y = count, fill = value, position = "fill"))+
scale_fill_manual(values = col.cat, breaks = c("Hyperarid","Arid","Semi-arid","Dry subhumid","Humid","NA"))+
scale_y_continuous(position = "right")+
theme_minimal()+
theme(axis.text.x = element_text(angle = 90, hjust = 1, vjust = 0.5),
legend.position = "bottom",
strip.text.x = element_text(size = 6))+
facet_grid(source ~ Continent, switch = "y", scales = "free_x", space = "free")+
labs(x = "", y = "Count", fill = "Aridity\ncategory")
vars <- c("lon","lat","Continent","Name","Acronym","tas","pr","sfcWind","Rn","ea","ET0","AI","cat.AI")
merge.vars <- c("lon","lat","Continent","Name","Acronym")
calib.wide <- select(era5vA, vars) %>%
merge(select(wdcvA, vars),
by = merge.vars) %>%
merge(select(cmip6vA, vars),
by = merge.vars) %>%
setNames(c(merge.vars,
"tas.era5","pr.era5", "sfcWind.era5","Rn.era5","ea.era5","ET0.era5","AI.era5","cat.AI.era5",
"tas.wdc","pr.wdc", "sfcWind.wdc","Rn.wdc","ea.wdc","ET0.wdc","AI.wdc","cat.AI.wdc",
"tas.cmip6","pr.cmip6", "sfcWind.cmip6","Rn.cmip6","ea.cmip6","ET0.cmip6","AI.cmip6","cat.AI.cmip6"))
In red: when CMIP6 or ERA5 are warmer than Wordlclim
cowplot::plot_grid(
ggplot(calib.wide)+
geom_raster(aes(x=lon, y = lat, fill = tas.era5-tas.wdc))+
scale_fill_continuous_divergingx(palette = "RdYlBu", mid = 0, rev = T, name = "Temperature in °C: ERA5 - WDC")+
theme_void()+
theme(legend.position = "bottom"),
ggplot(calib.wide)+
geom_raster(aes(x=lon, y = lat, fill = tas.cmip6-tas.wdc))+
scale_fill_continuous_divergingx(palette = "RdYlBu", mid = 0, rev = T, name = "Temperature in °C: CMIP6 - WDC")+
theme_void()+
theme(legend.position = "bottom")
)
In blue: when CMIP6 or ERA5 are wetter than Worldclim
cowplot::plot_grid(
ggplot(calib.wide)+
geom_raster(aes(x=lon, y = lat, fill = pr.era5-pr.wdc))+
scale_fill_continuous_divergingx(palette = "RdYlBu", mid = 0, name = "Precipitation in mm/y: ERA5 - WDC", guide = "legend")+
theme_void()+
theme(legend.position = "bottom"),
ggplot(calib.wide)+
geom_raster(aes(x=lon, y = lat, fill = pr.cmip6-pr.wdc))+
scale_fill_continuous_divergingx(palette = "RdYlBu", mid = 0, name = "Precipitation in mm/y: CMIP6 - WDC", guide = "legend")+
theme_void()+
theme(legend.position = "bottom")
)
In blue: when wind speed is higher for CMIP6 or ERA5 compared to Worldclim
cowplot::plot_grid(
ggplot(calib.wide)+
geom_raster(aes(x=lon, y = lat, fill = sfcWind.era5-sfcWind.wdc))+
scale_fill_continuous_divergingx(palette = "RdYlBu", mid = 0, name = "Wind speed in m/s: ERA5 - WDC", guide = "legend")+
theme_void()+
theme(legend.position = "bottom"),
ggplot(calib.wide)+
geom_raster(aes(x=lon, y = lat, fill = sfcWind.cmip6-sfcWind.wdc))+
scale_fill_continuous_divergingx(palette = "RdYlBu", mid = 0, name = "Wind speed in m/s: CMIP6 - WDC", guide = "legend")+
theme_void()+
theme(legend.position = "bottom")
)
Representing for scatterplot only tas, pr and sfcWind (Rn need checking in Wdc, ea needs checking in CMIP6)
cowplot::plot_grid(
ggplot(calib.wide,aes(x = sfcWind.wdc))+geom_point(aes( y = sfcWind.era5, col = "ERA5"))+
geom_point(aes(y=sfcWind.cmip6, col = "CMIP6"))+
geom_point(aes( y = sfcWind.era5), col = "white")+
geom_point(aes(y=sfcWind.cmip6), col = "white")+
labs(x="Wind speed m/s, WDC", y = "Wind speed m/s", col = "Dataset")+
scale_color_manual(values = c(colorvec[3], colorvec[9]))+
theme_void(base_size=15)+
theme(legend.position = "bottom"),
ggplot(calib.wide,aes(x = tas.wdc))+geom_point(aes( y = tas.era5, col = "ERA5"), alpha =0.4, shape = 1)+
geom_point(aes(y=tas.cmip6, col = "CMIP6"), alpha = 0.4, shape = 1)+
stat_poly_eq(aes(y = tas.era5, col = "ERA5")) +
stat_poly_eq(aes(y = tas.cmip6, col = "CMIP6"), label.x = "right",label.y = "bottom") +
geom_abline(slope = 1, intercept = 0)+
labs(x="Temperature in °C, WDC", y = "Temperature in °C", col = "Dataset")+
scale_color_manual(values = c(colorvec[3], colorvec[9]))+
theme_minimal()+
theme(legend.position = "none"),
ggplot(calib.wide,aes(x = pr.wdc))+geom_point(aes( y = pr.era5, col = "ERA5"), alpha =0.4, shape = 1)+
geom_point(aes(y=pr.cmip6, col = "CMIP6"), alpha = 0.4, shape = 1)+
stat_poly_eq(aes(y = pr.era5, col = "ERA5")) +
stat_poly_eq(aes(y = pr.cmip6, col = "CMIP6"), label.x = "right",label.y = "bottom") +
geom_abline(slope = 1, intercept = 0)+
labs(x="Annual precipitation, mm, WDC", y = "Annual precipitation, mm", col = "Dataset")+
scale_color_manual(values = c(colorvec[3], colorvec[9]))+
theme_minimal()+
theme(legend.position = "none"),
ggplot(calib.wide,aes(x = sfcWind.wdc))+geom_point(aes( y = sfcWind.era5, col = "ERA5"), alpha =0.4, shape = 1)+
geom_point(aes(y=sfcWind.cmip6, col = "CMIP6"), alpha = 0.4, shape = 1)+
stat_poly_eq(aes(y = sfcWind.era5, col = "ERA5")) +
stat_poly_eq(aes(y = sfcWind.cmip6, col = "CMIP6"), label.x = "right",label.y = "bottom") +
geom_abline(slope = 1, intercept = 0)+
labs(x="Wind speed m/s, WDC", y = "Wind speed m/s", col = "Dataset")+
scale_color_manual(values = c(colorvec[3], colorvec[9]))+
theme_minimal()+
theme(legend.position = "none"),
ggplot(calib.wide,aes(x = Rn.wdc))+geom_point(aes( y = Rn.era5, col = "ERA5"), alpha =0.4, shape = 1)+
geom_point(aes(y=Rn.cmip6, col = "CMIP6"), alpha = 0.4, shape = 1)+
stat_poly_eq(aes(y = Rn.era5, col = "ERA5")) +
stat_poly_eq(aes(y = Rn.cmip6, col = "CMIP6"), label.x = "right",label.y = "bottom") +
geom_abline(slope = 1, intercept = 0)+
labs(x="Rn, MJ/M2/m2, WDC, °C", y = "Rn, MJ/M2/m2", col = "Dataset")+
scale_color_manual(values = c(colorvec[3], colorvec[9]))+
theme_minimal()+
theme(legend.position = "none"),
ggplot(calib.wide,aes(x = ea.wdc))+geom_point(aes(y = ea.era5, col = "ERA5"), alpha =0.4, shape = 1)+
geom_point(aes(y=ea.cmip6, col = "CMIP6"), alpha = 0.4, shape = 1)+
stat_poly_eq(aes(y = ea.era5, col = "ERA5")) +
stat_poly_eq(aes(y = ea.cmip6, col = "CMIP6"), label.x = "right",label.y = "bottom") +
geom_abline(slope = 1, intercept = 0)+
labs(x="ea, kPa, WDC, °C", y = "ea, kPa", col = "Dataset")+
scale_color_manual(values = c(colorvec[3], colorvec[9]))+
theme_minimal()+
theme(legend.position = "none"),
ggplot(calib.wide,aes(x = ET0.wdc))+geom_point(aes(y = ET0.era5, col = "ERA5"), alpha =0.4, shape = 1)+
geom_point(aes(y=ET0.cmip6, col = "CMIP6"), alpha = 0.4, shape = 1)+
stat_poly_eq(aes(y = ET0.era5, col = "ERA5")) +
stat_poly_eq(aes(y = ET0.cmip6, col = "CMIP6"), label.x = "right",label.y = "bottom") +
geom_abline(slope = 1, intercept = 0)+
labs(x="ET0, mm/day, WDC", y = "ET0, mm/day", col = "Dataset")+
scale_color_manual(values = c(colorvec[3], colorvec[9]))+
theme_minimal()+
theme(legend.position = "none"),
ncol = 2
)
In red: when CMIP6 or WDC are warmer than ERA5
cowplot::plot_grid(
ggplot(calib.wide)+
geom_raster(aes(x=lon, y = lat, fill = tas.wdc-tas.era5))+
scale_fill_continuous_divergingx(palette = "RdYlBu", mid = 0, rev = T, name = "Temperature in °C: WDC - ERA5")+
theme_void()+
theme(legend.position = "bottom"),
ggplot(calib.wide)+
geom_raster(aes(x=lon, y = lat, fill = tas.cmip6-tas.era5))+
scale_fill_continuous_divergingx(palette = "RdYlBu", mid = 0, rev = T, name = "Temperature in °C: CMIP6 - ERA5")+
theme_void()+
theme(legend.position = "bottom")
)
In blue: when CMIP6 or WDC are wetter than ERA5
cowplot::plot_grid(
ggplot(calib.wide)+
geom_raster(aes(x=lon, y = lat, fill = pr.wdc-pr.era5))+
scale_fill_continuous_divergingx(palette = "RdYlBu", mid = 0, name = "Precipitation in mm/y: WDC - ERA5", guide = "legend")+
theme_void()+
theme(legend.position = "bottom"),
ggplot(calib.wide)+
geom_raster(aes(x=lon, y = lat, fill = pr.cmip6-pr.era5))+
scale_fill_continuous_divergingx(palette = "RdYlBu", mid = 0, name = "Precipitation in mm/y: CMIP6 - ERA5", guide = "legend")+
theme_void()+
theme(legend.position = "bottom")
)
In blue: when wind speed is higher for CMIP6 or WDC compared to ERA5
cowplot::plot_grid(
ggplot(calib.wide)+
geom_raster(aes(x=lon, y = lat, fill = sfcWind.wdc-sfcWind.era5))+
scale_fill_continuous_divergingx(palette = "RdYlBu", mid = 0, name = "Wind speed in m/s: WDC - ERA5", guide = "legend")+
theme_void()+
theme(legend.position = "bottom"),
ggplot(calib.wide)+
geom_raster(aes(x=lon, y = lat, fill = sfcWind.cmip6-sfcWind.era5))+
scale_fill_continuous_divergingx(palette = "RdYlBu", mid = 0, name = "Wind speed in m/s: CMIP6 - ERA5", guide = "legend")+
theme_void()+
theme(legend.position = "bottom")
)
Representing for scatterplot only tas, pr and sfcWind (Rn need checking in Wdc, ea needs checking in CMIP6)
cowplot::plot_grid(
ggplot(calib.wide,aes(x = sfcWind.era5))+geom_point(aes( y = sfcWind.wdc, col = "WDC"))+
geom_point(aes(y=sfcWind.cmip6, col = "CMIP6"))+
geom_point(aes( y = sfcWind.wdc), col = "white")+
geom_point(aes(y=sfcWind.cmip6), col = "white")+
labs(x="Wind speed m/s, ERA5", y = "Wind speed m/s", col = "Dataset")+
scale_color_manual(values = c(colorvec[3], colorvec[9]))+
theme_void(base_size=15)+
theme(legend.position = "bottom"),
ggplot(calib.wide,aes(x = tas.era5))+geom_point(aes(y = tas.wdc, col = "WDC"), alpha =0.4, shape = 1)+
geom_point(aes(y=tas.cmip6, col = "CMIP6"), alpha = 0.4, shape = 1)+
stat_poly_eq(aes(y = tas.wdc, col = "WDC")) +
stat_poly_eq(aes(y = tas.cmip6, col = "CMIP6"), label.x = "right",label.y = "bottom") +
geom_abline(slope = 1, intercept = 0)+
labs(x="Temperature in °C, ERA5", y = "Temperature in °C", col = "Dataset")+
scale_color_manual(values = c(colorvec[3], colorvec[9]))+
theme_minimal()+
theme(legend.position = "none"),
ggplot(calib.wide,aes(x = pr.era5))+geom_point(aes( y = pr.wdc, col = "WDC"), alpha =0.4, shape = 1)+
geom_point(aes(y=pr.cmip6, col = "CMIP6"), alpha = 0.4, shape = 1)+
stat_poly_eq(aes(y = pr.wdc, col = "WDC")) +
stat_poly_eq(aes(y = pr.cmip6, col = "CMIP6"), label.x = "right",label.y = "bottom") +
geom_abline(slope = 1, intercept = 0)+
labs(x="Annual precipitation, mm, ERA5", y = "Annual precipitation, mm", col = "Dataset")+
scale_color_manual(values = c(colorvec[3], colorvec[9]))+
theme_minimal()+
theme(legend.position = "none"),
ggplot(calib.wide,aes(x = sfcWind.era5))+geom_point(aes( y = sfcWind.wdc, col = "WDC"), alpha =0.4, shape = 1)+
geom_point(aes(y=sfcWind.cmip6, col = "CMIP6"), alpha = 0.4, shape = 1)+
stat_poly_eq(aes(y = sfcWind.wdc, col = "WDC")) +
stat_poly_eq(aes(y = sfcWind.cmip6, col = "CMIP6"), label.x = "right",label.y = "bottom") +
geom_abline(slope = 1, intercept = 0)+
labs(x="Wind speed m/s, ERA5", y = "Wind speed m/s", col = "Dataset")+
scale_color_manual(values = c(colorvec[3], colorvec[9]))+
theme_minimal()+
theme(legend.position = "none"),
ggplot(calib.wide,aes(x = Rn.era5))+geom_point(aes( y = Rn.wdc, col = "WDC"), alpha =0.4, shape = 1)+
geom_point(aes(y=Rn.cmip6, col = "CMIP6"), alpha = 0.4, shape = 1)+
stat_poly_eq(aes(y = Rn.wdc, col = "WDC")) +
stat_poly_eq(aes(y = Rn.cmip6, col = "CMIP6"), label.x = "right",label.y = "bottom") +
geom_abline(slope = 1, intercept = 0)+
labs(x="Rn, MJ/m2/day, ERA5, °C", y = "Rn, W/MJ/m2/day", col = "Dataset")+
scale_color_manual(values = c(colorvec[3], colorvec[9]))+
theme_minimal()+
theme(legend.position = "none"),
ggplot(calib.wide,aes(x = ea.era5))+geom_point(aes( y = ea.wdc, col = "WDC"), alpha =0.4, shape = 1)+
geom_point(aes(y=ea.cmip6, col = "CMIP6"), alpha = 0.4, shape = 1)+
stat_poly_eq(aes(y = ea.wdc, col = "WDC")) +
stat_poly_eq(aes(y = ea.cmip6, col = "CMIP6"), label.x = "right",label.y = "bottom") +
geom_abline(slope = 1, intercept = 0)+
labs(x="ea, kPa, ERA5", y = "ea, kPa", col = "Dataset")+
scale_color_manual(values = c(colorvec[3], colorvec[9]))+
theme_minimal()+
theme(legend.position = "none"),
ggplot(calib.wide,aes(x = ET0.era5))+geom_point(aes(y = ET0.wdc, col = "WDC"), alpha =0.4, shape = 1)+
geom_point(aes(y=ET0.cmip6, col = "CMIP6"), alpha = 0.4, shape = 1)+
stat_poly_eq(aes(y = ET0.wdc, col = "WDC")) +
stat_poly_eq(aes(y = ET0.cmip6, col = "CMIP6"), label.x = "right",label.y = "bottom") +
geom_abline(slope = 1, intercept = 0)+
labs(x="ET0, mm/day, ERA5", y = "ET0, mm/day", col = "Dataset")+
scale_color_manual(values = c(colorvec[3], colorvec[9]))+
theme_minimal()+
theme(legend.position = "none"),
ncol = 2
)
# Download Gimms NDVI
library(gimms)
library(gganimate)
land_mask <- raster("Masks/land_sea_mask_1degree.nc4")
land_mask.df <- as.data.frame(land_mask, xy = T) %>% setNames(c("lon","lat","lm")) # 0 if ocean, 1 if land
#ndvi.ref <- downloadGimms(x= 1981,y= 2000,dsn = "NDVI")
list.ndvi <- list.files(path = "NDVI", pattern = "ndvi.*\\.nc4$", full.names = T)[1:2]
ndvi.rast <- rasterizeGimms(list.ndvi, keep = 0) %>% mean(na.rm = T) %>% projectRaster(land_mask) # rasterize Gimms does the quality control and removes NAs
ndvi.df <- ndvi.rast %>% as.data.frame(xy = T) %>% setNames(c("lon","lat","ndvi")) %>% merge(land_mask.df, by = c("lon","lat")) %>% filter(lm != 0)
write.table(ndvi.df, "NDVI/ndvi.df.txt")
ndvi.df <- read.table("NDVI/ndvi.df.txt")
ggplot(subset(ndvi.df, lm == 1))+geom_tile(aes(x=lon, y = lat, fill = ndvi))+
scale_fill_continuous_sequential(palette = "Greens 3", rev = T)+
ylim(-55,90)+labs(fill = "NDVI")+
theme_void()+theme(legend.position = "bottom")
calibn <- merge(calib, ndvi.df, by = c("lon","lat"))
ggplot(subset(calibn, !is.na(cat.AI)))+geom_boxplot(aes(x=cat.AI, y = ndvi, col = cat.AI))+facet_grid(rows = vars(source))+
scale_color_manual(values = col.cat)+
labs(x = "", y = "NDVI")+
theme_minimal()+theme(legend.position = "none")
aov(ndvi~cat.AI, data = group_by(calibn, source)) %>% summary()
## Df Sum Sq Mean Sq F value Pr(>F)
## cat.AI 5 1037 207.41 8762 <2e-16 ***
## Residuals 43524 1030 0.02
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 26211 observations effacées parce que manquantes
range.ndvi <- calibn %>% filter(!is.na(cat.AI)) %>% group_by(source, cat.AI) %>%
summarise(range.ndvi = paste(round(range(ndvi, na.rm = T),2), collapse = " to ")) %>%
cast(source~cat.AI)
cor.ndvi <- calibn %>% filter(!is.na(cat.AI)) %>% group_by(source, cat.AI) %>%
summarise(pearson.r = round(cor(ndvi, AI, use = "pairwise.complete"),2)) %>%
cast(source~cat.AI)
knitr::kable(range.ndvi, caption = "NDVI range by source and aridity category")
| source | Cold | Hyperarid | Arid | Semi-arid | Dry subhumid | Humid |
|---|---|---|---|---|---|---|
| CMIP6 | -0.13 to 0.77 | 0.04 to 0.22 | 0.04 to 0.54 | 0.01 to 0.82 | 0.01 to 0.82 | -0.01 to 0.92 |
| ERA5 | -0.13 to 0.81 | 0.04 to 0.53 | 0.01 to 0.46 | -0.01 to 0.73 | 0.04 to 0.82 | -0.01 to 0.92 |
| Worldclim | -0.13 to 0.77 | 0.04 to 0.53 | -0.03 to 0.47 | -0.04 to 0.72 | 0.03 to 0.72 | -0.08 to 0.93 |
knitr::kable(cor.ndvi, caption = "Correlation between NDVI and AI by source and aridity category")
| source | Cold | Hyperarid | Arid | Semi-arid | Dry subhumid | Humid |
|---|---|---|---|---|---|---|
| CMIP6 | -0.08 | 0.15 | 0.36 | 0.38 | -0.01 | 0.31 |
| ERA5 | -0.16 | 0.08 | 0.47 | 0.30 | 0.08 | 0.38 |
| Worldclim | 0.06 | 0.05 | 0.49 | 0.39 | 0.14 | 0.51 |